COLOR_NONE=\x1b[0m
COLOR_COMPILE=\x1b[32;01m
COLOR_BUILD=\x1b[35;01m
COLOR_CLEAN=\x1b[31;01m

FLAGS_COMPILE_SDL=`pkg-config sdl --cflags`
FLAGS_LINK_SDL=`pkg-config sdl --libs`

FLAGS_COMPILE_LUA=`pkg-config lua5.1 --cflags`
FLAGS_LINK_LUA=`pkg-config lua5.1 --libs`

FLAGS_LINK_FREEIMAGE=-lfreeimageplus

FLAGS_COMPILE_GSL=`pkg-config gsl --cflags`
FLAGS_LINK_GSL=`pkg-config gsl --libs`


FLAGS_COMPILE=-march=native -O3 -I ../include/ $(FLAGS_COMPILE_SDL) $(FLAGS_COMPILE_LUA) $(FLAGS_COMPILE_GSL)
FLAGS_LINK=-lpthread $(FLAGS_LINK_SDL) $(FLAGS_LINK_LUA) $(FLAGS_LINK_FREEIMAGE) $(FLAGS_LINK_GSL)
APP_NAME=tsoc
OBJECTS=RayTracer.o Math.o Obj3DLoader.o Graph.o Color.o Config.o Scene.o Core.o Photon.o SdlTracer.o Filter.o


all:  $(APP_NAME)

test: $(OBJECTS) test.o
	@echo -e '$(COLOR_BUILD)* Building [$@]$(COLOR_NONE)'
	g++ -o test test.o $(OBJECTS) $(FLAGS_LINK)


$(APP_NAME): $(OBJECTS) main.o
	@echo -e '$(COLOR_BUILD)* Building [$@]$(COLOR_NONE)'
	g++ -o $(APP_NAME) main.o $(OBJECTS) $(FLAGS_LINK)
	
	
%.o : %.cpp
	@echo -e '$(COLOR_COMPILE)* Compiling [$<]$(COLOR_NONE)'
	g++ -c $< $(FLAGS_COMPILE)

%.o : %.c
	@echo -e '$(COLOR_COMPILE)* Compiling [$<]$(COLOR_NONE)'
	g++ -c $< $(FLAGS_COMPILE)
 	

clean:
	@echo -e '$(COLOR_BUILD)* Cleaning$(COLOR_NONE)'
	rm -f $(APP_NAME)
	rm -f $(OBJECTS)


